package  com.matea.order.controller;

import com.matea.product.client.ProductClient;
import com.matea.product.common.DecreaseStockInput;
import com.matea.product.common.ProductInfoOutput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * Created by Matea on 2018/11/21.
 */
@RestController
@Slf4j
public class ClientController {

    @Autowired
    private ProductClient productClient;

    @GetMapping("/getProductMsg")
    public String getProductMsg(){
        //String response = productClient.productMsg();
        //log.info("response={}",response);
        //return  response;
        return "";
    }

    @GetMapping("/getProductList")
    public  String getProductList(){
         List<ProductInfoOutput> productInfoList=productClient.listForOrder(Arrays.asList("164103465734242707"));
        log.info("response={}",productInfoList);
        return  "ok";
    }

    @GetMapping("/productDecreaseStock")
    public String productDecreaseStock(){
        productClient.decreaseStock(Arrays.asList(new DecreaseStockInput("164103465734242707",2)));
        return "ok";
    }
}
